<!doctype html>
<html class="no-js" lang="">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>作业提交系统V1.0</title>
    <meta name="description" content="作业提交系统V1.0">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css@8.0.0/normalize.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/lykmapipo/themify-icons@0.1.2/css/themify-icons.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pixeden-stroke-7-icon@1.2.3/pe-icon-7-stroke/dist/pe-icon-7-stroke.min.css">
    <link rel="stylesheet" href="assets/css/cs-skin-elastic.css">
    <link rel="stylesheet" href="assets/css/style.css">

	<!--引入fontawesome-->
	<link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.min.css">
    <!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/html5shiv/3.7.3/html5shiv.min.js"></script> -->

	<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0/axios.min.js"></script>
</head>
<body class="bg-dark">

    <div class="sufee-login d-flex align-content-center flex-wrap">
        <div class="container">
            <div class="login-content">
                <div class="login-logo">
                    <a href="#">
                        <i class="fa fa-user-o fa-5x" aria-hidden="true"></i> 
                    </a>
                </div>
                <div class="login-form">
                    <form>
                        <div class="form-group">
                            <label>用户名</label>
                            <input id="username" type="email" class="form-control" placeholder="Username">
                        </div>
                        <div class="form-group">
                            <label>密码</label>
                            <input id="password" type="password" class="form-control" placeholder="Password">
                        </div>
                        <div class="checkbox">
                           
                            <label class="pull-right">
                                <a href="login.html">学生端</a>
                            </label>

                        </div>
                        <div class="card-body" align="center">
                        	<input type="button"   class="btn btn-success" value="登录"     onclick="pri()"></button>	
                        </div>
                        
                        
                    </form>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/jquery@2.2.4/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.4/dist/umd/popper.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/js/bootstrap.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/jquery-match-height@0.7.2/dist/jquery.matchHeight.min.js"></script>
    <script src="assets/js/main.js"></script>
	<script type="text/javascript">
		function loadaccount1(){
			//alert("welcome!");
			window.localStorage.clear();
		}
		
		window.onload=loadaccount1();
	</script>
	
	<script type="text/javascript">
	function pri(){
	    var form1 = document.getElementById('username').value;
		var form2 = document.getElementById('password').value;
			if(form1 == "" || form2 == "") {
				alert("输入错误 请检查.");
			}
		//var f;
		
		axios.get(
				'http://172.81.214.138:8000/teacher_login?username='+form1+'&password='+form2)
			//成功返回
			.then(response => {
				console.log(response);
				if(response.data.state==1){
					//alert('登陆成功');
					if(response.data.data.level<2){
						//是老师
						window.localStorage.setItem("TUsername", form1);//存userName
						window.location.assign('tea-dataOfClass.html');
					}
					else{
						window.localStorage.setItem("AUsername", form1);//存userName
						window.location.assign('adm-dataOfSetClass.html');
					}
					
				}
				else{
					alert('登录失败！');
				}
			})
			//失败返回
			.catch(error => {
				console.log(error);
			})
			
	   
		
	    return true;
	}
	</script>
</body>
</html>
